<?php

namespace App\Models\Traits;

trait GoldBeanTrait
{
	public static function allowedLowestTransferBeans()
	{
		return big_decimal(cs('storm')->allowed_lowest_transfer_gold_beans);
	}
	
	public static function allowedTransferMultiple()
	{
		return big_decimal(cs('storm')->allowed_transfer_gold_beans_multiple);
	}
	
	public static function isLowestTransferBeansMatched($beans)
	{
		$allowedLowestBeans = self::allowedLowestTransferBeans();
		if ($allowedLowestBeans->isGreaterThan(0)) {
			return big_decimal($beans)->isGreaterThanOrEqualTo($allowedLowestBeans);
		}
		return true;
	}
	
	public static function isTransferMultipleMatched($beans)
	{
		$allowedMultiple = self::allowedTransferMultiple();
		$remainder = big_decimal($beans)->remainder($allowedMultiple);
		return $remainder->isEqualTo(0);
	}
}
